﻿using System;
using System.Runtime.InteropServices;

namespace Alex.Library.Win32
{
    /// <summary>
    /// Win32 SDK中与文件操作相关的API
    /// </summary>
    public sealed class FileApi
    {
        /// <summary>
        /// 拷贝文件
        /// </summary>
        /// <param name="lpExistingFileName">源文件名</param>
        /// <param name="lpNewFileName">目标文件名</param>
        /// <param name="bFailIfExists">如果设为TRUE（非零），那么一旦目标文件已经存在，则函数调用会失败。否则目标文件被改写</param>
        /// <returns>非零表示成功，零表示失败。会设置GetLastError</returns>
        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall,
            SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool CopyFile([MarshalAs(UnmanagedType.LPWStr)]string lpExistingFileName,
          [MarshalAs(UnmanagedType.LPWStr)]string lpNewFileName, [MarshalAs(UnmanagedType.Bool)]bool bFailIfExists);
    }
}
